/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2024-08-14
 * Time: 19:09
 */
class Solution {
    public List<Integer> List=new ArrayList();
    public List<Integer> preorderTraversal(TreeNode root) {
        preorderTraversal2(root);
        return List;
    }
    public void preorderTraversal2(TreeNode root){
        if(root==null){
            return;
        }
        List.add(root.val);
        preorderTraversal2(root.left);
        preorderTraversal2(root.right);
    }
}
